﻿using System.Globalization;
using System.Windows.Data;
using DimensionsHelper.Common.Contracts.Excel;

namespace DimensionsHelper.Client.Converters;

public class BorderStyleToStrokeThicknessConverter : IValueConverter
{
    public double Hair { get; set; } = 0.5;

    public double Thin { get; set; } = 1;

    public double Medium { get; set; } = 1.5;

    public double Thick { get; set; } = 2;


    public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        BorderStyle style = BorderStyle.None;

        if (value is BorderStyle borderStyle)
        {
            style = borderStyle;
        }

        switch (style)
        {
            case BorderStyle.None:
                return 0d;

            case BorderStyle.Hair:
                return Hair;

            case BorderStyle.Thin:
            case BorderStyle.Dotted:
            case BorderStyle.DashDot:
            case BorderStyle.DashDotDot:
            case BorderStyle.Dashed:
            case BorderStyle.Double:
                return Thin;

            case BorderStyle.Medium:
            case BorderStyle.MediumDashDotDot:
            case BorderStyle.MediumDashed:
            case BorderStyle.MediumDashDot:
                return Medium;

            case BorderStyle.Thick:
                return Thick;
        }

        return 0d;
    }

    public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        return Binding.DoNothing;
    }
}